package com.zhiyou100.action;

import com.zhiyou100.exception.MyException;
import com.zhiyou100.service.Test01Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * 异常处理 action
 *
 * @author yang
 * @version 1.0.0
 * @date 2020-09-02 20:55
 */
@Controller
@RequestMapping("/test01")
public class Test01Action {
    @Autowired
    private Test01Service service;

    @RequestMapping("/login.action")
    public String loginMethod(String sname, String spwd, HttpSession session) {
        if (!service.pdSname(sname)) {
            throw new MyException("账户不存在 ！ ");
        }

        if (!service.pdSnameAndSpwd(sname, spwd)) {
            throw new MyException("密码错误！");
        }

        session.setAttribute("sname", sname);

        return "test01/success";

    }


}
